package DataStructureAndAlgorithm.AcWing_每日一题.贪心题;
import java.util.Scanner;
//贪心
//链接：https://www.acwing.com/problem/content/3779/
public class AcWing_3776 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int j = 0; j < t; j++){
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int e = in.nextInt();
            int f = in.nextInt();
            int res = 0;
            //如果一的利润更大
            if (e > f){
                int min = Math.min(a,d);
                a -= min;
                d -= min;
                res += min * e;
                if (d >= 0){
                    min = Math.min(Math.min(b,c),d);
                    res += min * f;
                }
            }else {
                int min = Math.min(Math.min(b,c),d);
                b -= min;
                c -= min;
                d -= min;
                res += min * f;
                if (d >= 0){
                    min = Math.min(a,d);
                    res += min * e;
                }
            }
            System.out.println(res);
        }
        in.close();
    }
}
